<?php

/**
 * View helper for javascript based validation.
 * @author Steve
 */
class Demo_ValidationMessage extends Zend_View_Helper_Abstract
{
	public function validationMessage($messageId) {
		$result = $this->view->translate($messageId);		
		$result = str_replace("%value%", "_val_", $result);
		
		foreach (func_get_args() as $arg) {
			if ($arg == $messageId) {
				continue;
			}
			
			$result = preg_replace("/%[^%]*%/", $arg, $result, 1);
		}
		
		return $result;
	}
	
	/**
	 * Registers this helper in given view instance.
	 * @param Zend_View_Interface $view
	 */
	public static function register(Zend_View_Interface $view) {
		$view->addHelperPath( "Demo", "Demo_" );
	}	
} 